import { IsString, IsJSON, IsEnum, IsPhoneNumber, IsArray, Min, Length, IsOptional, IsBoolean, IsNumber, IsNumberString, IsEmail, IsDateString } from 'class-validator';
import { ApiProperty, PartialType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';

export enum StatusEnum {
    STATIC = '0',
    DYNAMIC = '1',
    DELETED = '2'
}

export enum MenuTypeEnum {
    MODULE = '1',
    MENU = '2',
    BUTTON = '3',
    LINK = '4'
}

export class CreateMenuDto {
    @ApiProperty({ required: true })
    @Length(0,50)
    menuid: string; 

    @ApiProperty({ required: true })
    @Length(0,50)
    name: string; 

    @ApiProperty({ required: true })
    @Length(0,50)
    code: string; 

    @ApiProperty({ required: true })
    @Length(0,50)
    @IsEnum(MenuTypeEnum)
    type: string;

    @ApiProperty({ required: true })
    @Length(0,50)
    url: string;
    
    @ApiProperty({ required: true })
    @Length(0,50)
    parentid:string

    @ApiProperty({ required: true })
    @Length(0,50)
    component: string; 

    @ApiProperty({ required: true })
    @Length(0,50)
    status?: string; 

    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    @Length(0, 500)
    remark?: string;

    @ApiProperty({ required: true })
    @IsOptional()
    @IsDateString()
    create_time?: string;


}

export class UpdateMenuDto extends PartialType(CreateMenuDto) {
    @ApiProperty({ required: true })
    @IsOptional()
    @IsDateString()
    update_time: string;
  
    @ApiProperty({
      required: true,
    })
    @IsString()
    @Length(0,50)
    menuid: string;
}

export class ListMenuDto extends PagingDto {

    @ApiProperty({ required: false })
    @IsString()
    @Length(0, 50)
    menuid: string;
  
    @ApiProperty({ required: false })
    @IsString()
    @Length(0, 50)
    name: string;
  
    @ApiProperty({ required: false })
    @IsString()
    @Length(0, 50)
    code: string;

    @ApiProperty({ required: false })
    @IsString()
    @Length(0, 50)
    component:string;
  
    @ApiProperty({ required: false })
    @IsString()
    type: string;
  
    @ApiProperty({ required: false })
    @IsString()
    parentid: string;

    @ApiProperty({ required: false })
    @IsString()
    create_time: string;

    @ApiProperty({ required: false })
    @IsOptional()
    url: string;
}